﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NMortgage.UI.Model;

namespace NMortgage.UI.ViewModels
{
    public sealed class PeriodicPaymentViewModel
    {
        private PeriodicPayment Payment { get; set; }

        public int Period { get { return Payment.Period; } }
        public double BeginingBalance { get { return Payment.BeginingBalance; } }
        public double StandardPayment { get { return Payment.StandardPayment; } }
        public double ExtraPayment { get { return Payment.ExtraPayment; } }
        public double PaymentMade { get { return Payment.PaymentMade; } }
        public double PrincipleDue { get { return Payment.PrincipleDue; } }
        public double InterestDue { get { return Payment.InterestDue; } }
        public double EndingBalance { get { return Payment.EndingBalance; } }
        public double CumulativePrincipal { get { return Payment.CumulativePrincipal; } }
        public double CumulativeInterest { get { return Payment.CumulativeInterest; } }
        public DateTime PaymentDate { get { return Payment.PaymentDate; } }
        public string InterestDescription { get; private set; }
        
        public PeriodicPaymentViewModel(PeriodicPayment payment, MortgageProfile profile)
        {
            Payment = payment;
            int periodicFactor = profile.PaymentFrequency == PaymentFrequency.Monthly ? 12 : 26;
            InterestDescription = string.Format("{0:#0.####}%", (payment.InterestRate * 100 / periodicFactor));
        }
    }
}
